package com.example.commom.comment;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class BooleanValueValidator implements ConstraintValidator<BooleanValue, Boolean> {

    @Override
    public void initialize(BooleanValue constraintAnnotation) {
    }

    @Override
    public boolean isValid(Boolean value, ConstraintValidatorContext context) {
        // 布尔值只能为 true 或 false，否则校验失败
        return value != null;
    }
}